export function printAction(col, listItem, istable=false,key=null) {
    if(col.length <= 0 || JSON.stringify(listItem) === '{}') {
        return ''
    }
    let htmlItemStr = '', printData = [], items ;
    col.forEach((item, index) => {
        if(key){
            if(item[key]){
                printData[index] = {}
                printData[index].label = item.label
                printData[index].prop = item.prop
            }
        }else{
            printData[index] = {}
            printData[index].label = item.label
            printData[index].prop = item.prop
        }
    })
    printData.forEach((pri) => {
        items = pri.prop
        // if(listItem?.items) {
        pri.value = listItem[items]?listItem[items]:''
        // }
    })
    let tag = istable?'':':'
    printData.forEach((it,ind) => {
        if(istable){
            if(ind%2==0){
                htmlItemStr +=`<tr><td class="tableFont">${it.label}</td><td class="tableFont">${it.value}</td></tr>`
            }else{
                htmlItemStr +=`<tr><td class="tableFont">${it.label}</td><td class="tableFont">${it.value}</td></tr>`
            }
            // htmlItemStr +=index%2==0?'<tr>':''+'<td>'+index%2==0?item.label:item.value+'</td>'+index%2==0?''+'</tr>':''
        }else{
            htmlItemStr += `<div class="print-cont"><label class="print-label">${it.label} ${tag}</label><label class="print-label">${it.value}</label></div>`
        }
        
    })
    htmlItemStr += `<style>html,body,div{height: auto!important;}</style>`;
    istable?htmlItemStr=`<table  border="1">${htmlItemStr}</table>`:''
    return htmlItemStr
} 